<template>
	<div class="login-wrap">
		<div class="ms-login">
			<div class="ms-title">后台管理系统注册</div>
			<el-form label-width="70px" :model="param" :rules="rules" ref="login"  class="ms-content">
                
                <el-form-item label="手机号">
					<el-input  v-model="form.Phone"></el-input>
				</el-form-item>
                
                <el-form-item label="邮箱">
					<el-input  v-model="form.Email"></el-input>
				</el-form-item>
                
				<el-form-item label="用户名">
					<el-input v-model="form.UserName"></el-input>
				</el-form-item>
					<el-form-item label="密码" v-if="title!='编辑'">
					<el-input v-model="form.PassWord"></el-input>
				</el-form-item>
                <el-form-item label="姓名">
					<el-input v-model="form.NickName"></el-input>
				</el-form-item>
                
                	<el-form-item label="年龄">
					<el-input type="number" v-model.number="form.Age"></el-input>
				</el-form-item>
                
                <el-form-item label="性别">
					<el-select v-model.number="form.Sex" placeholder="性别" class="handle-select mr10">
					<el-option key="1" label="男" :value="Number(1)"></el-option>
					<el-option key="2" label="女" :value="Number(2)"></el-option>
				</el-select>
				</el-form-item>
                 

                <el-form-item label="备注">
					<el-input  v-model="form.Remake"></el-input>
				</el-form-item>
				
				<div class="login-btn">
					
					<el-button type="primary" @click="submitForm">注册</el-button>
				</div>
				<p class="login-tips"></p>
			</el-form>
		</div>
	</div>
</template>

<script setup lang="ts">
import { ref, reactive } from 'vue';
import { useTagsStore } from '../store/tags';
import { usePermissStore } from '../store/permiss';
import { useRouter } from 'vue-router';
import { ElMessage } from 'element-plus';
import type { FormInstance, FormRules } from 'element-plus';
import {Add} from '../api/user/user'

interface User{
        Age:number;
        Datetime: string;
        Email: string;
        ID: number;
        NickName: string;
        PassWord: string;
        Phone: string;
        Remake: string;
        Roleid: number;
        Sex: number;
        UserName:string;
}

const router = useRouter();
const form = reactive<User>({} as User);

const rules: FormRules = {
	UserName: [
		{
			required: true,
			message: '请输入用户名',
			trigger: 'blur'
		}
	],
	Password: [{ required: true, message: '请输入密码', trigger: 'blur' }]
};
const permiss = usePermissStore();
const login = ref<FormInstance>();
const ToRegist=()=>{
	router.push("/regist")
}
const submitForm = (formEl: FormInstance | undefined) => {
	Add(form).then(res=>{
		ElMessage.success('注册成功');
		router.push("/Login")
	})
	
};

const tags = useTagsStore();
tags.clearTags();
</script>

<style scoped>
.login-wrap {
	position: relative;
	width: 100%;
	height: 100%;
	background-image: url(../assets/img/login-bg.jpg);
	background-size: 100%;
}
.ms-title {
	width: 100%;
	line-height: 50px;
	text-align: center;
	font-size: 20px;
	color: #fff;
	border-bottom: 1px solid #ddd;
}
.ms-login {
	position: absolute;
	left: 50%;
	top: 30%;
	width: 500px;
	margin: -190px 0 0 -175px;
	border-radius: 5px;
	background: rgba(255, 255, 255, 0.3);
	overflow: hidden;
}
.ms-content {
	padding: 50px;
}
.login-btn {
	text-align: center;
}
.login-btn button {
	width: 100%;
	height: 36px;
	margin-bottom: 10px;
}
.login-tips {
	font-size: 12px;
	line-height: 30px;
	color: #fff;
}
</style>
